   /*the default options for jquery.form plugin */
   var options = {
        beforeSubmit:  ShowLoader,  // pre-submit callback
        success:       showResponse,  // post-submit callback
        dataType:   "json"        // 'xml', 'script', or 'json' (expected server response type)
    };


	function showResponse(data, statusText, xhr, $form){
	   if(data.success){
		   
       	}
      
	   if(data.error){
		  
		  if(data.islogin){
    		  alert(data.error);
    	  }
    	  else{
    			$("#loader").hide("fast");
    			$("div.form").show("fast");
    		  $("#errorDescription").html(data.error);
    	  }
	   }
	   if(data.refresh){
		  var delay = 0;
    	  if(data.delay){
    		  delay = data.delay;
    	  }
    	  else{
    		  delay = 1;
    	  }
    	  setTimeout("location.reload(true)", delay*1000); 
	   }
	   if(data.redirect)	{
		   window.location = data.redirect;
	   }
	}

  function ShowLoader()
   {
	  $("div.form").hide("fast");
	  $("#loader").css("padding-left", "40px");
	  $("#loader").css("padding-top", "30px");
	  $(".ui-dialog").css("vertical-align", "middle");
	  $(".ui-dialog").css("text-align", "center");
	  $("#loader").show("fast");
//	  $('body').css('cursor', 'wait');
   }
  function HideLoader()
   {
	  $("#loader").hide("fast");
	  $("div.form").show("fast");
//	  $('body').css('cursor', 'default');
   }

   /* Submit a form, ajax post method */
   function Send(id_form){
       $(id_form).ajaxSubmit(options);
	   return false;
   }